//
//  MainTabBarViewController.m
//  WeiWeiHaircut
//
//  Created by 超群 on 15/10/8.
//  Copyright © 2015年 超群. All rights reserved.
//

#import "MainTabBarViewController.h"
#import "QZShopViewController.h"
#import "ShaoppingCarViewController.h"
#import "QZMeViewController.h"
#import "QZHairstyleViewController.h"
#import "MyAppointmentViewController.h"


@interface MainTabBarViewController () <UITabBarControllerDelegate>

@end

@implementation MainTabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self createTabBarAndNavgationBar];
    [super.navigationController setNavigationBarHidden:YES animated:TRUE];

}

- (void)viewWillDisappear:(BOOL)animated
{
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)createTabBarAndNavgationBar {
    
    self.selectedIndex           = 0;
    self.tabBar.tintColor        = SBpurpleColor;
    self.delegate = self;
    
    
    UIFont *font                                = [UIFont systemFontOfSize:13];
    NSDictionary* barTitleDictionaryNormal      = @{NSFontAttributeName            :font,
                                                    NSForegroundColorAttributeName :TabBarTitleColor};
    NSDictionary* barTitleDictionarySelected    = @{NSFontAttributeName            :font,
                                                    NSForegroundColorAttributeName :SBpurpleColor};
    //tabbar正常
    [[UITabBarItem appearance] setTitleTextAttributes:barTitleDictionaryNormal forState:UIControlStateNormal];
    //tabbar选中
    [[UITabBarItem appearance] setTitleTextAttributes:barTitleDictionarySelected forState:UIControlStateSelected];
    
    [[UITabBarItem appearance] setTitlePositionAdjustment:UIOffsetMake(0, 0)];
    
    //发型
    QZHairstyleViewController* hairStyleVC    = [[QZHairstyleViewController alloc] initWithNibName:nil bundle:nil];
    UINavigationController* nav1        = [[UINavigationController alloc] initWithRootViewController:hairStyleVC];
    [nav1.navigationBar setBackgroundImage:[UIImage imageNamed:@"QZNavgationImage.png"] forBarMetrics:UIBarMetricsDefault];
    [nav1.navigationBar setTintColor:SBpurpleColor];
    nav1.tabBarItem                     = [[UITabBarItem alloc]initWithTitle:@"发型"
                                                                       image:[UIImage imageNamed:@"发型.png"]
                                                               selectedImage:[UIImage imageNamed:@"发型-选中.png"]];
    
    //商品
    QZShopViewController* goodsVC = [[QZShopViewController alloc] initWithNibName:nil bundle:nil];
    UINavigationController* nav2         = [[UINavigationController alloc] initWithRootViewController:goodsVC];
    [goodsVC.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"QZNavgationImage.png"] forBarMetrics:UIBarMetricsDefault];
    [nav2.navigationBar setTintColor:SBpurpleColor];
    nav2.tabBarItem                      = [[UITabBarItem alloc]initWithTitle:@"商品"
                                                                        image:[UIImage imageNamed:@"商品.png"]
                                                                selectedImage:[UIImage imageNamed:@"商品-选中.png"]];
    
    //预约
    MyAppointmentViewController* resertationVC        = [[MyAppointmentViewController  alloc]init];
    UINavigationController* nav3        = [[UINavigationController alloc] initWithRootViewController:resertationVC];
    [resertationVC.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"QZNavgationImage.png"] forBarMetrics:UIBarMetricsDefault];
    [nav3.navigationBar setTintColor:SBpurpleColor];
    nav3.tabBarItem                     = [[UITabBarItem alloc]initWithTitle:@"预约"
                                                                       image:[UIImage imageNamed:@"预约.png"]
                                                               selectedImage:[UIImage imageNamed:@"预约-选中.png"]];
    
    //购物车
    ShaoppingCarViewController*   shoppingVC          = [[ShaoppingCarViewController alloc] initWithNibName:nil bundle:nil];
    UINavigationController* nav4        = [[UINavigationController alloc] initWithRootViewController:shoppingVC];
    [shoppingVC.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"QZNavgationImage.png"] forBarMetrics:UIBarMetricsDefault];
    [nav4.navigationBar setTintColor:SBpurpleColor];
    nav4.tabBarItem                     = [[UITabBarItem alloc]initWithTitle:@"购物车"
                                                                       image:[UIImage imageNamed:@"购物车.png"]
                                                               selectedImage:[UIImage imageNamed:@"购物车-选中.png"]];
    
    //我
    QZMeViewController*   meVC          = [[QZMeViewController alloc] initWithNibName:nil bundle:nil];
    UINavigationController* nav5        = [[UINavigationController alloc] initWithRootViewController:meVC];
    [meVC.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"QZNavgationImage.png"] forBarMetrics:UIBarMetricsDefault];
    [nav5.navigationBar setTintColor:SBpurpleColor];
    nav5.tabBarItem                     = [[UITabBarItem alloc]initWithTitle:@"我"
                                                                       image:[UIImage imageNamed:@"我的.png"]
                                                               selectedImage:[UIImage imageNamed:@"我的-选中.png"]];
    
    self.viewControllers = @[nav1, nav2,nav3, nav4,nav5];
}


@end
